<template>
  <div class="out-box">
    <div class="content-ab" v-if="screenWidth > 1024 && !isMobile()">
      <div v-for="(item, index) in detailsList" :key="index">
        <scrollHandle>
          <div v-if="item.type == 1" class="type1-pc">
            <div class="type1-pc-left">{{ item.left.substring(0, 5)  }}<br>{{ item.left.substring(5)  }}</div>
            <div class="type1-pc-right">{{ item.right }}</div>
          </div>
          <div v-if="item.type == 2" class="type2-pc">
            <div class="type2-pc-txt">
              {{ item.value }}
            </div>
           
          </div>
          <div v-if="item.type == 3" class="type3-pc">
            <div  class="type3-pc-pic">
              <el-image class="imgdable" :src="baseApi + item.left" fit="cover" />
            </div>
            <div  class="type3-pc-pic">
              <el-image class="imgdable" :src="baseApi + item.right" fit="cover" />
            </div>
          </div>
          <div v-if="item.type == 4" class="type4-pc">
            <el-image class="imgstyle" :src="baseApi + item.value" fit="cover" />
          </div>
          <div v-if="item.type == 5" class="type5-pc">
            <video width="100%" height="800" controls>
              <source :src="baseApi + item.value" type="video/mp4">
              <source :src="baseApi + item.value"  type="video/ogg">
              <source :src="baseApi + item.value"  type="video/webm">
              您的浏览器不支持 video 标签。
            </video>
          </div>
        </scrollHandle>
      </div>
    </div>
    <div class="content-ab-mobel" v-if="screenWidth <= 1024 || isMobile()">
      <div v-for="(item, index) in detailsList" :key="index">
        <scrollHandle>
          <div v-if="item.type == 1" class="type1-pc-mobel">
            <div class="type1-pc-left-mobel">{{ item.left.substring(0, 5)  }}<br>{{ item.left.substring(5)  }}</div>
            <div class="type1-pc-right-mobel">{{ item.right }}</div>
          </div>
          <div v-if="item.type == 2" class="type2-pc-mobel">
            <div class="type2-pc-txt-mobel">
              {{ item.value }}
            </div>
           
          </div>
          <div v-if="item.type == 3" class="type3-pc-mobel">
            <div  class="type3-pc-pic-mobel">
              <el-image class="imgdable-mobel" :src="baseApi + item.left" fit="cover" />
            </div>
            <div  class="type3-pc-pic-mobel">
              <el-image class="imgdable-mobel" :src="baseApi + item.right" fit="cover" />
            </div>
          </div>
          <div v-if="item.type == 4" class="type4-pc-mobel">
            <el-image class="imgstyle-mobel" :src="baseApi + item.value" fit="cover" />
          </div>
          <div v-if="item.type == 5" class="type5-pc-mobel">
            <video width="100%" :height="screenWidth/2" controls>
              <source :src="baseApi + item.value" type="video/mp4">
              <source :src="baseApi + item.value"  type="video/ogg">
              <source :src="baseApi + item.value"  type="video/webm">
              您的浏览器不支持 video 标签。
            </video>
          </div>
        </scrollHandle>
      </div>
    </div>

  </div>
</template>

<script>
import scrollHandle from "@/components/scrollHandle.vue";
export default {
  components: {
    scrollHandle,
  },
  props: {
    detailsData: {
      style: Object,
      default: () => {
        return {}
      }
    }
  },
  data() {
    return {
      screenWidth: window.innerWidth,
      bannerImgList: '',
      baseApi: process.env.VUE_APP_IMGADDRESS,
      brandData: '',
      detailsList: '',
    };
  },
  watch: {
    detailsData: {
      handler: function (newVal, oldVal) {
        if (newVal && newVal.detail) {
          this.detailsList = JSON.parse(newVal.detail)
        }
      },
      deep: true,
      immediate: true
    }
  },

  mounted() {
    window.addEventListener("resize", this.getScreenSise);

  },
  methods: {
    isMobile() {
      const userAgentInfo = navigator.userAgent;
      const mobileAgents = [
        "Android",
        "iPhone",
        "SymbianOS",
        "Windows Phone",
        "iPad",
        "iPod",
      ];
      const mobileFlag = mobileAgents.some((mobileAgent) => {
        return userAgentInfo.indexOf(mobileAgent) > 0;
      });

      let isPro = /Version\/.* Safari/.test(userAgentInfo); // 检查是否有Safari标识，通常iPad Pro才会有

      // 更精确的检测方式，检查屏幕尺寸或像素比（PPI）
      let pixelRatio = window.devicePixelRatio;
      let isHighResolution = pixelRatio >= 2; // iPad Pro的大约分辨率为1024x1366，像素比为2或3

      let isipadpro = isPro && isHighResolution;
      console.log(isipadpro, isPro, isHighResolution);
      let isiPad = (navigator.userAgent.match(/(iPad)/) || (navigator.userAgent.match(/(Macintosh)/) && navigator.maxTouchPoints >= 1));

      return mobileFlag || isiPad;
    },
    getScreenSise() {
      this.screenWidth = window.innerWidth;
    },

  },
};
</script>

<style lang="scss" scoped>
.out-box {
  background-color: #fff;
  width: 100%;
}

.content-ab {
  padding: 0 100px;
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
}

.imgdable {
  width: 100%;
  height: 100%;
  max-height: 600px;
}
.imgstyle {
  width: 100%;
  height: 100%;
  max-height: 800px;
}
.type1-pc{
  padding: 200px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 48px;
}
.type1-pc-left{
  font-family: "BebasFontB";
  font-size: 70px;
  line-height: 80px;
  // text-align: justify;
  white-space: pre-line;
}
.type1-pc-right{
  font-family: "BebasFont";
  font-size: 30px;
  line-height: 40px;
  // text-align: justify;
  white-space: pre-line;
}
.type2-pc{
  display: flex;
  width: 100%;
  justify-content: flex-end;
  padding: 200px 0;
}
.type2-pc-txt{
  width: 50%;
  font-family: "BebasFont";
  font-size: 30px;
  line-height: 40px;
  // text-align: justify;
  white-space: pre-line;
}
.type3-pc{
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 48px;
  padding-top:48px;
}
.type3-pc-pic{
  width: 100%;
}
.type4-pc{
  margin-top:48px;
  width: 100%;
}
.type5-pc{
  width: 100%;
  padding-top: 48px;
}


.content-ab-mobel {
  background-color: #fff;
  padding: 0 3.2rem;
  width: 100%;
}


.imgdable-mobel {
  width: 100%;
  height: 100%;
  max-height: 60rem;
}
.imgstyle-mobel {
  width: 100%;
  height: 100%;
  max-height: 80rem;
}
.type1-pc-mobel{
  padding: 20rem 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-gap: 4.8rem;
}
.type1-pc-left-mobel{
  font-family: "BebasFontB";
  font-size: 7rem;
  line-height: 8rem;
  // text-align: justify;
  white-space: pre-line;
}
.type1-pc-right-mobel{
  font-family: "BebasFont";
  font-size: 2.8rem;
  line-height: 4.1rem;
  // text-align: justify;
  white-space: pre-line;
}
.type2-pc-mobel{
  display: flex;
  width: 100%;
  justify-content: flex-end;
  padding: 20rem 0;
}
.type2-pc-txt-mobel{
  width: 100%;
  font-family: "BebasFont";
  font-size: 2.8rem;
  line-height: 4.1rem;
  // text-align: justify;
  white-space: pre-line;
}
.type3-pc-mobel{
  display: grid;
  grid-template-columns: 1fr;
  grid-gap: 4.8rem;
  padding-top:4.8rem;
}
.type3-pc-pic-mobel{
  width: 100%;
}
.type4-pc-mobel{
  padding-top:4.8rem;
  width: 100%;
}
.type5-pc-mobel{
  width: 100%;
  padding-top: 4.8rem;
}
</style>